package com.sun.weekend.view.refresh;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.AbsListView;

import com.sun.weekend.view.FixedListView;

/**
 * @author Administrator
 */

public class ReFreshListView extends RefreshLayoutBase<FixedListView> implements AbsListView.OnScrollListener {

    public ReFreshListView(Context context) {
        this(context,null);
    }

    public ReFreshListView(Context context, AttributeSet attrs) {
        this(context, attrs,0);
    }

    public ReFreshListView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);

    }

    @Override
    protected void setUpContentView(Context context) {
        contentView = new FixedListView(context);
        contentView.setOnScrollListener(this);
    }

    @Override
    protected boolean isTop() {
        return contentView.getFirstVisiblePosition() == 0
                && getScrollY() <= headerView.getMeasuredHeight();
    }

    @Override
    protected boolean isBottom() {
        return contentView != null && contentView.getAdapter() != null
                && contentView.getLastVisiblePosition() == contentView.getAdapter().getCount()-1;
    }

    @Override
    public void onScrollStateChanged(AbsListView view, int scrollState) {

    }

    @Override
    public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {

    }
}
